#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import platform
import os


class OSSupport:

    @staticmethod
    def getPlateform():
        """
        获取平台类型
        :return:
        """
        return platform.system()

    @staticmethod
    def getHome():
        """
        获取用户主目录
        :return:
        """
        sysstr = platform.system()
        if sysstr == "Windows":
            return os.path.expanduser('~') + os.path.sep
        elif sysstr == "Linux":
            return os.environ['HOME'] + os.path.sep
        elif sysstr == "Darwin":  # mac
            return os.environ['HOME'] + os.path.sep
        else:
            print('other')

    @staticmethod
    def exists(file):
        """
        判断文件是否存在
        :param file:
        :return:
        """
        return os.path.exists(file)

    @staticmethod
    def mkdir(fileDir):
        """
        创建目录
        :param fileDir:
        :return:
        """
        return os.mkdir(fileDir)

    @staticmethod
    def getSeparator():
        """
        获取文件路径分隔符
        :return:
        """
        return os.sep

    @staticmethod
    def isFile(file):
        """
        判断是否文件
        :param file:
        :return:
        """
        return os.path.isfile(file)

    @staticmethod
    def isDir(file):
        """
        判断是否目录
        :param file:
        :return:
        """
        return os.path.isdir(file)

    @staticmethod
    def getFileExtension(file):
        """
        获取文件名后缀
        :param file:
        :return:
        """
        return os.path.splitext(file)[1]

    @staticmethod
    def getCurrentDir():
        """
        获取当前目录
        :return:
        """
        return os.getcwd()


if __name__ == '__main__':
    print(OSSupport.getHome())
